# -*- coding: utf-8 -*-
from Page.sessionPage import sessionPage
from Page.noscanningPage import noscanningPage
import time
import os
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
class session():
    def __init__(self,driver):
        self.driver=driver
        self.sessionPage=sessionPage(self.driver)
        self.noscanningPage=noscanningPage(self.driver)
    # 点击团险业务
    def grouplife(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("head")
        time.sleep(1)
        self.sessionPage.btnGroup().click()
        time.sleep(1)
    # 点击收付费管理
    def acceptpayment(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraMenu")
        time.sleep(1)
        self.sessionPage.btnAcceptPayment().click()
        time.sleep(1)
    def payManagement(self,RecAccountNum):
        self.sessionPage.btnPayMan().click()
        time.sleep(1)
        self.sessionPage.btnSessionApply().click()
        time.sleep(1)
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        self.sessionPage.inpRecAccountNum().send_keys(RecAccountNum)
        time.sleep(1)
        self.sessionPage.btnQuery().click()
        time.sleep(1)
        self.sessionPage.btnTempFeeInfoGridChk().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        window2 = self.driver.window_handles
        self.driver.switch_to.window(window2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
    def paymentifm(self,AgentName,GrpName,Money,ConfirmDesc,BUssGrid1,BUssGrid2,BUssGrid3):
        self.sessionPage.inptAgentName().send_keys(AgentName)
        time.sleep(1)
        self.sessionPage.inptGrpName().send_keys(GrpName)
        time.sleep(1)
        self.sessionPage.inpMoney().send_keys(Money)
        time.sleep(1)
        self.sessionPage.inpConfirmDesc().send_keys(ConfirmDesc)
        time.sleep(1)
        ActionChains(self.driver).double_click(self.sessionPage.btnBUssGrid1()).perform()
        time.sleep(1)
        Select(self.sessionPage.secBUssGrid1()).select_by_visible_text(BUssGrid1)
        time.sleep(1)
        self.sessionPage.inpBUssGrid2().send_keys(BUssGrid2)
        time.sleep(1)
        self.sessionPage.inpBUssGrid3().send_keys(BUssGrid3)
        time.sleep(1)
        self.sessionPage.btnAdd().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.noscanningPage.butSubmit().click()
        window2 = self.driver.window_handles
        self.driver.switch_to.window(window2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        self.sessionPage.btnTempFeehGridSel().click()
        time.sleep(1)
        self.sessionPage.btnUpload().click()
        time.sleep(1)
        window3 = self.driver.window_handles
        self.driver.switch_to.window(window3[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        ActionChains(self.driver).double_click(self.sessionPage.btnAttachType()).perform()
        time.sleep(1)
        Select(self.sessionPage.secAttachType()).select_by_visible_text('01-付款凭证')
        time.sleep(1)
        self.sessionPage.btnUploadPath().click()
        time.sleep(1)
        os.system(r'C:\Users\tanjm.ext\PycharmProjects\GroupL\TestData\uploadAttach.exe')
        time.sleep(1)
        self.sessionPage.btnUploadButton().click()
        time.sleep(1)
        window4 = self.driver.window_handles
        self.driver.switch_to.window(window4[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        window5 = self.driver.window_handles
        self.driver.switch_to.window(window5[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        self.sessionPage.btnClose().click()
        time.sleep(1)
        window6 = self.driver.window_handles
        self.driver.switch_to.window(window6[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        self.sessionPage.btnSubmit().click()
        time.sleep(1)
        window6 = self.driver.window_handles
        self.driver.switch_to.window(window6[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)


















